package doubleLinkedList;

public class Test {

    public static void main(String[] args) {
        DoubleLinkedList doubleLinkedList1 = new DoubleLinkedList();

        System.out.println("使用头插法创建双向循环链表：");
        doubleLinkedList1.addFirst(2);
        doubleLinkedList1.addFirst(8);
        doubleLinkedList1.addFirst(16);
        doubleLinkedList1.addFirst(28);
        doubleLinkedList1.addFirst(1998);

        System.out.println("进行打印：");
        doubleLinkedList1.display();

        DoubleLinkedList doubleLinkedList2 = new DoubleLinkedList();
        System.out.println("使用尾插法创建双向循环链表：");
        doubleLinkedList2.addLast(2);
        doubleLinkedList2.addLast(8);
        doubleLinkedList2.addLast(2);
        doubleLinkedList2.addLast(2);
        doubleLinkedList2.addLast(1998);
        doubleLinkedList2.display();

        System.out.println("求链表长度（此处针对链表2）：");
        System.out.println(doubleLinkedList2.size());

        System.out.println("任意位置插入（从0开始）：");
        doubleLinkedList1.addIndex(2,52);
        doubleLinkedList1.display();

        System.out.println("判断是否包含：");
        System.out.println(doubleLinkedList1.contains(52));

        System.out.println("进行首次出现删除：");
        doubleLinkedList2.remove(2);
        doubleLinkedList2.display();

        System.out.println("进行所有出现都删除：");
        doubleLinkedList2.removeAllKey(2);
        doubleLinkedList2.display();

        System.out.println("进行清空：");
        doubleLinkedList1.clear();
        doubleLinkedList1.display();

    }
}
